<!--
  
   CivEditor.xaml
  
   Copyright (c) 2007 Mike Strobel
  
   This source code is subject to the terms of the Microsoft Reciprocal License (Ms-RL).
   For details, see <http://www.opensource.org/licenses/ms-rl.html>.
  
   All other rights reserved.
  
  -->
<local:EditorBase x:Class="Supremacy.Editor.CivEditor"
             xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
             xmlns:av="http://schemas.codeplex.com/wpfcontrib/xaml/presentation"
             xmlns:s="clr-namespace:Supremacy.Client;assembly=SupremacyWPF"
             xmlns:local="clr-namespace:Supremacy.Editor"
             xmlns:tech="clr-namespace:Supremacy.Tech;assembly=SupremacyCore"
             xmlns:buildings="clr-namespace:Supremacy.Buildings;assembly=SupremacyCore"
             xmlns:entities="clr-namespace:Supremacy.Entities;assembly=SupremacyCore"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <local:EditorBase.CommandBindings>
    <CommandBinding Command="{x:Static ApplicationCommands.New}"
                    CanExecute="CommandBinding_CanExecute"
                    Executed="CommandBinding_Executed" />
    <CommandBinding Command="{x:Static ApplicationCommands.Delete}"
                    CanExecute="CommandBinding_CanExecute"
                    Executed="CommandBinding_Executed" />
  </local:EditorBase.CommandBindings>

  <local:EditorBase.Resources>
    <local:RaceIdToRaceConverter x:Key="RaceIdToRaceConverter" />
  </local:EditorBase.Resources>

  <DockPanel>
  
    <GroupBox DockPanel.Dock="Bottom"
              Margin="12"
              Padding="0,6,0,0"
              HorizontalAlignment="Left">
      <GroupBox.Header>
        <CheckBox x:Name="DefineHomeSystemCheckBox"
                  Content="Define Home System"
                  FontWeight="Bold"
                  IsChecked="{Binding ElementName=HomeSystemEditor, Path=IsEnabled, Mode=OneWayToSource}" />
      </GroupBox.Header>
      <local:HomeSystemEditor x:Name="HomeSystemEditor"
                              HorizontalAlignment="Left" />
    </GroupBox>
    
    <StackPanel DockPanel.Dock="Right"
                Margin="12"
                Orientation="Vertical"
                VerticalAlignment="Top">

      <ToolBarTray IsLocked="True"
                   HorizontalAlignment="Left">
        <ToolBar>
          <Label FontWeight="Bold"
                 Content="Tech Tree" />
          <Button x:Name="AddTechItemButton"
                  Click="AddTechItemButton_Click">
            <Image Source="Resources/BlankPage16.png"
                   Width="16"
                   Height="16" />
          </Button>
          <Button x:Name="DeleteTechItemButton"
                  Click="DeleteTechItemButton_Click">
            <Image Source="Resources/Delete16.png"
                   Width="16"
                   Height="16" />
          </Button>
        </ToolBar>
      </ToolBarTray>
      <TreeView x:Name="TechTree"
                MaxWidth="256"
                MinWidth="160"
                Height="512">
      </TreeView>
    </StackPanel>

    <av:AutoGrid DockPanel.Dock="Top"
                 Margin="12"
                 Orientation="Vertical">
      <av:AutoGrid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"
                          SharedSizeGroup="EditorLeftColumnGroup" />
        <ColumnDefinition Width="*" />
      </av:AutoGrid.ColumnDefinitions>

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=IdentityText}"
             Content="Identity:"
             FontWeight="Bold" />
      <TextBox x:Name="IdentityText"
               TabIndex="0"
               Margin="2,3,2,3"
               MinWidth="128"
               MaxWidth="256"
               HorizontalAlignment="Left"
               CharacterCasing="Upper">
        <TextBox.Text>
          <Binding Path="Key"
                   Mode="TwoWay">
            <Binding.ValidationRules>
              <local:NonEmptyValidationRule />
            </Binding.ValidationRules>
          </Binding>
        </TextBox.Text>
      </TextBox>

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=ShortNameText}"
             Content="Short Name:"
             FontWeight="Bold" />
      <TextBox Name="ShortNameText"
               Margin="2,3,2,3"
               MinWidth="128"
               MaxWidth="256"
               HorizontalAlignment="Left">
        <TextBox.Text>
          <Binding Path="ShortName"
                   Mode="TwoWay">
            <Binding.ValidationRules>
              <local:NonEmptyValidationRule />
            </Binding.ValidationRules>
          </Binding>
        </TextBox.Text>
      </TextBox>

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=LongNameText}"
             Content="Long Name:"
             FontWeight="Bold" />
      <TextBox Name="LongNameText"
               Margin="2,3,2,3"
               MinWidth="192"
               MaxWidth="512"
               HorizontalAlignment="Left">
        <TextBox.Text>
          <Binding Path="LongName"
                   Mode="TwoWay">
            <Binding.ValidationRules>
              <local:NonEmptyValidationRule />
            </Binding.ValidationRules>
          </Binding>
        </TextBox.Text>
      </TextBox>

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=DiplomacyReportText}"
             Content="Diplomacy Report:"
             FontWeight="Bold" />
      <TextBox Name="DiplomacyReportText"
               Height="128"
               Margin="2,3,2,3"
               TextWrapping="Wrap"
               VerticalScrollBarVisibility="Visible"
               AcceptsReturn="True"
               Text="{Binding Path=DiplomacyReport, Mode=TwoWay}" />

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=HomeSystemNameText}"
             Content="Home System Name:"
             FontWeight="Bold" />
      <TextBox Name="HomeSystemNameText"
               Margin="2,3,2,3"
               MinWidth="128"
               MaxWidth="256"
               HorizontalAlignment="Left"
               Text="{Binding Path=HomeSystemName, Mode=TwoWay}" />

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=ColorText}"
             Content="Color:"
             FontWeight="Bold" />
      <TextBox Name="ColorText"
               Margin="2,3,2,3"
               MinWidth="128"
               MaxWidth="512"
               HorizontalAlignment="Left"
               Text="{Binding Path=Color, Mode=TwoWay}" />

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=QuadrantList}"
             Content="Home Quadrant:"
             FontWeight="Bold" />
      <ComboBox Name="QuadrantList"
                Margin="2,3,2,3"
                MinWidth="128"
                HorizontalAlignment="Left"
                SelectedItem="{Binding Path=HomeQuadrant, Mode=TwoWay}" />

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=CivilizationTypeList}"
             Content="Civilization Type:"
             FontWeight="Bold" />
      <ComboBox Name="CivilizationTypeList"
                Margin="2,3,2,3"
                MinWidth="128"
                HorizontalAlignment="Left"
                SelectedItem="{Binding Path=CivilizationType, Mode=TwoWay}" />

      <Label Margin="0,3,2,3"
             Target="{Binding ElementName=TechCurveList}"
             Content="Tech Curve:"
             FontWeight="Bold" />
      <ComboBox Name="TechCurveList"
                Margin="2,3,2,3"
                MinWidth="128"
                HorizontalAlignment="Left"
                SelectedItem="{Binding Path=TechCurve, Mode=TwoWay}" />

    </av:AutoGrid>

    <GroupBox DockPanel.Dock="Top" Margin="12,0,12,0">
      <GroupBox.Header>
        <Grid>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
          </Grid.ColumnDefinitions>
          <Label Grid.Column="0"
                 Margin="0,3,2,3"
                 VerticalAlignment="Center"
                 Target="{Binding ElementName=RaceList}"
                 Content="Native Race"
                 FontWeight="Bold" />
          <ComboBox Grid.Column="1"
                    Name="RaceList"
                    Margin="2,3,2,3"
                    SelectedItem="{Binding Path=RaceID, Converter={StaticResource RaceIdToRaceConverter}, Mode=TwoWay}"
                    TextSearch.TextPath="PluralName">
            <ComboBox.Resources>
              <DataTemplate DataType="{x:Type entities:Race}">
                <TextBlock Text="{Binding Path=PluralName}" />
              </DataTemplate>
            </ComboBox.Resources>
          </ComboBox>
          <Button x:Name="NewRaceButton"
                  Grid.Column="2"
                  Margin="2,3,2,3"
                  Content="New..."
                  Visibility="Collapsed" />
        </Grid>
      </GroupBox.Header>
      <local:RaceEditor DataContext="{Binding Path=RaceID, Converter={StaticResource RaceIdToRaceConverter}}" />
    </GroupBox>
  </DockPanel>
</local:EditorBase>
